package com.lanxiao.cloud.modules.user.controller.dubbo;

import com.lanxiao.cloud.common.core.dto.UserBaseDto;
import com.lanxiao.cloud.common.core.exception.BusinessException;
import com.lanxiao.cloud.modules.user.application.UserCmdManager;
import com.lanxiao.cloud.modules.user.application.UserQueryManager;
import com.lanxiao.cloud.modules.user.application.dto.UserDto;
import com.lanxiao.cloud.user.api.UserDubboApi;
import com.lanxiao.cloud.user.api.dto.LoginInfoDubboUpdate;
import com.lanxiao.cloud.user.api.dto.UserDubboAdd;
import com.lanxiao.cloud.user.api.dto.UserDubboDto;
import java.util.List;
import java.util.Map;
import org.apache.dubbo.config.annotation.DubboService;

/**
 * @author ：qiaoliang
 * @date ：2021-09-13
 */
@DubboService
public class UserDubboController implements UserDubboApi {

  private final UserCmdManager userCmdManager;
  private final UserQueryManager userQueryManager;

  public UserDubboController(
      UserCmdManager userCmdManager,
      UserQueryManager userQueryManager) {
    this.userCmdManager = userCmdManager;
    this.userQueryManager = userQueryManager;
  }

  @Override
  public void loginInfoUpdate(LoginInfoDubboUpdate loginDubboUpdate) {
    userCmdManager.loginInfoUpdate(loginDubboUpdate);
  }

  @Override
  public UserDubboDto checkLogin(Long userId) {
    return userQueryManager.checkLogin(userId);
  }

  @Override
  public Long register(UserDubboAdd userDubboAdd) {
    return userCmdManager.register(userDubboAdd);
  }

  @Override
  public Map<Long, UserBaseDto<Long>> findByIds(List<Long> ids) {
    return userQueryManager.findByIds(ids);
  }

}
